Skip to content

fix(shield): protect component and GKE Autopilot labels - #2799

Merged
matteo-porta merged 1 commit into
mainfrom
matteo/shield-label-precedence
Nov 3, 2026
Merged

matteo-porta merged 1 commit into
mainfrom
matteo/shield-label-precedence

Conversation

@matteo-porta

@matteo-porta matteo-porta commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

Component-level labels can override the built-in sysdig/component label and GKE Autopilot labels. This can make rendered resources carry the wrong identity or allowlist labels.

Merge the built-in labels before user-supplied component labels for cluster, host and Windows host resources. Preserve user component label precedence over global labels.

This carries the fix from #2748 onto main.

Testing

  • Four label-precedence tests failed on main and pass with this change.
  • helm unittest --strict -f 'tests/*/*_test.yaml' ./charts/shield: 697 tests passed.
  • make lint and make -o deps-unittest unittest passed. The lint command disables version increment checking.

Checklist

  • Title starts with type and scope.
  • Shield chart version bumped.
  • No new values require documentation.
  • GitHub Actions checks reviewed.
  • Tests are in the tests folder and have a _test suffix.

@matteo-porta
matteo-porta requested a review from a team as a code owner November 3, 2026 12:25
@matteo-porta
matteo-porta force-pushed the matteo/shield-label-precedence branch from 5705189 to 1a62392 Compare November 3, 2026 12:28
@matteo-porta
matteo-porta requested review from aroberts87 and a balanced review from Copilot November 3, 2026 12:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the label-precedence change.

No open issues 🎉

What changed in this PR

Carries the label-precedence fix from #2748 onto main, protecting Shield’s built-in component and GKE Autopilot labels while preserving component labels’ precedence over global labels.

Changes:

  • Merge protected labels before user-supplied component labels for cluster, Linux host, and Windows host resources.
  • Add four regression tests covering component identity and GKE Autopilot labels.
  • Bump the Shield chart version from 1.55.0 to 1.55.1.
File Description
charts/​shield/​tests/​host/​daemonset-windows_test.yaml Tests protection of the Windows host component label.
charts/​shield/​tests/​host/​daemonset_test.yaml Tests protection of host component and Autopilot labels.
charts/​shield/​tests/​cluster/​deployment_test.yaml Tests protection of the cluster component label.
charts/​shield/​templates/​host/​_windows_labels.tpl Gives built-in Windows host labels precedence.
charts/​shield/​templates/​host/​_labels.tpl Gives built-in host and Autopilot labels precedence.
charts/​shield/​templates/​cluster/​_labels.tpl Gives built-in cluster labels precedence.
charts/​shield/​Chart.yaml Updates the chart version to 1.55.1.

Review effort: Balanced

…nd GKE Autopilot labels

Sprig's merge keeps the value from the leftmost source on a key
collision. cluster.labels, host.labels and host_windows.labels were
merged before the chart's own component labels, so a user value for
sysdig/component (or, on GKE Autopilot, the autopilot.gke.io/no-connect
and cloud.google.com/matching-allowlist labels) replaced the built-in
one. Merge the built-in labels first. Global labels were already
merged after them.
@matteo-porta
matteo-porta enabled auto-merge (squash) November 3, 2026 16:41
@aroberts87
aroberts87 force-pushed the matteo/shield-label-precedence branch from 1a62392 to 540ecc9 Compare November 3, 2026 16:41
@matteo-porta
matteo-porta merged commit 2008d23 into main Nov 3, 2026
6 checks passed
@matteo-porta
matteo-porta deleted the matteo/shield-label-precedence branch November 3, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants